

package com.hexinfo.dmpro.sparing.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hexinfo.dmpro.common.annotation.AnonymousAccess;
import org.springframework.http.ResponseEntity;
import com.hexinfo.dmpro.sparing.model.HotStandbyTable;
import com.hexinfo.dmpro.sparing.service.HotStandbyTableService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;


/**
 * 热备表级同步记录表
 *
 * @author yemw
 * @date 2024-04-28 14:19:29
 */
@RestController
@AllArgsConstructor
@RequestMapping("/api/hotStandbyTable" )
@Api(value = "hotStandbyTable", tags = "热备表级同步记录表管理")
public class HotStandbyTableController {

    private final  HotStandbyTableService hotStandbyTableService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param hotStandbyTable 热备表级同步记录表
     * WrapperEnhancer.like(hotStandbyTable); //自动拼接存在值sql的方法
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page" )
    @AnonymousAccess
    public ResponseEntity<Object> getHotStandbyTablePage(Page page, HotStandbyTable hotStandbyTable) {
        return ResponseEntity.ok(hotStandbyTableService.queryList(page,hotStandbyTable));
    }


    /**
     * 通过id查询热备表级同步记录表
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}" )
    @AnonymousAccess
    public ResponseEntity<Object> getById(@PathVariable("id" ) String id) {
        return ResponseEntity.ok(hotStandbyTableService.getById(id));
    }

    /**
     * 新增热备表级同步记录表
     * @param hotStandbyTable 热备表级同步记录表
     * @return R
     */
    @ApiOperation(value = "新增热备表级同步记录表", notes = "新增热备表级同步记录表")
    @PostMapping
    @AnonymousAccess
    public ResponseEntity<Object> save(@RequestBody HotStandbyTable hotStandbyTable) {
        return ResponseEntity.ok(hotStandbyTableService.save(hotStandbyTable));
    }

    /**
     * 修改热备表级同步记录表
     * @param hotStandbyTable 热备表级同步记录表
     * @return R
     */
    @ApiOperation(value = "修改热备表级同步记录表", notes = "修改热备表级同步记录表")
    @PutMapping
    @AnonymousAccess
    public ResponseEntity<Object> updateById(@RequestBody HotStandbyTable hotStandbyTable) {
        return ResponseEntity.ok(hotStandbyTableService.updateById(hotStandbyTable));
    }

    /**
     * 通过id删除热备表级同步记录表
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除热备表级同步记录表", notes = "通过id删除热备表级同步记录表")
    @DeleteMapping("/{id}" )
    @AnonymousAccess
    public ResponseEntity<Object> removeById(@PathVariable String id) {
        return ResponseEntity.ok(hotStandbyTableService.remove(id));
    }

}
